package com.baomidou.springboot.util;

import java.sql.SQLException;

import javax.sql.DataSource;

public class DataSourceUtil {

	public  static String getDatabaseProductName() throws SQLException {
		DataSource dataSource = (DataSource) SpringContextUtils.getBean("dataSource");
		System.out.println(dataSource.getConnection().isClosed());
		String databaseProductName = dataSource.getConnection().getMetaData().getDatabaseProductName();
		dataSource.getConnection().close();
		
		return databaseProductName;
	}
	
	public  static Boolean isMysql() throws Exception {
		if (("MySQL").equals(getDatabaseProductName())) {
			return true;
		}
		return false;
}
}
